<template>
  <div class="box">
    <Head
      :title="`${this.$route.query.title}`"
      style="border-bottom: 2px solid #dad9df"
      id="backstyle"
    >
    <img src="../../../assets/black_star.png" alt="" />
    </Head>
    <div class="to">
      <!-- 文化背景区域 -->
      <div class="area-center">
        <!-- 内容区域 -->
        <div class="context richText bold-size" v-html="text"></div>
      </div>
    </div>
    <!-- 视频区域 -->
    <div class="video">
      <video-player
        style="height: 100%; margin: 0 auto; box-shadow: 5px 5px 8px #888888"
        class="video-player vjs-custom-skin"
        ref="videoPlayer"
        :playsinline="true"
        :options="playerOptions"
      ></video-player>
    </div>
  </div>
</template>

<script >
import { findByTitle } from "@/api/index";
import Head from "@/components/public/HeadPage.vue";
export default {
  components: {
    Head,
  },
  data() {
    return {
      playerOptions: {
        playbackRates: [0.7, 1.0, 1.5, 2.0],
        autoplay: false,
        muted: false,
        loop: false,
        preload: "auto",
        language: "zh-CN",
        aspectRatio: "16:9",
        fluid: true,
        sources: [
          {
            type: "video/mp4",
            src: "",
          },
        ],
        poster: "",

        notSupportedMessage: "此视频暂无法播放，请稍后再试",
        controlBar: {
          timeDivider: true,
          durationDisplay: true,
          remainingTimeDisplay: false,
          fullscreenToggle: true,
        },
      },
      list: [],
      text: "",
    };
  },
  mounted() {
    findByTitle({
      id: this.$route.query.id,
    }).then((res) => {
      if (res.data.code == 200) {
        this.list = res.data.data.video;
        this.text = this.dataHTML(res.data.data.context);
        this.playerOptions.sources[0].src = `http://175.178.155.112:8080${this.list}`;
        // this.playerOptions.sources[0].src = imgurl+`${this.list}`;
      }
    });
  },
  // methods: {
  //   // 进入全屏时，放大视频
  //   fullscreen() {
  //     const videoElem = this.$refs.videoPlayer.$el;
  //     videoElem.style.width = '100%';
  //     videoElem.style.height = '100%';
  //   },
  //   // 退出全屏时，还原视频大小
  //   exitFullscreen() {
  //     const videoElem = this.$refs.videoName.$el;
  //     videoElem.style.width = '';
  //     videoElem.style.height = '';
  //   }
  // },
};
</script>

<style scoped>
.box {
  width: 100%;

}
.to {
  width: 100%;
  /* height:2rem; */
  display: flex;
  flex-direction: column;
  align-items: center;
  /* justify-content: center; */
}
/* 头标区域 */
.Head_top img {
  margin-right: 0.05rem;
  width: 0.2rem;
  height: 0.2rem;
}
.center {
  width: 98%;
}
.xiao {
  width: 100%;

  display: flex;
  background-color: white;
}
/* 左边区域 */
.xiao .left {
  width: 5%;
  height: 100%;
  margin-left: 0.2rem;
}

.zhong {
  padding-left: 0.1rem;
  line-height: 0.27rem;
  font-weight: 700;
}
h3 {
  height: 0.3rem;
  line-height: 0.3rem;
  text-align: center;
  border-radius: 0.1rem;
  margin: 0.05rem 0;
  background-color: white;
}
/* 内容区域 */
.context {
  width: 100%;
  min-height: 0.5rem;
 margin-top: 0.05rem;
}

/* 视频区域 */
.video {
  width: 100%;
  height: 2rem;
  /* object-fit: cover; */
  padding-bottom: 0.25rem;
}
</style>